<template>
  <div class="collect-item">
    <div v-if="data.banner" class="collect-item__banner">
      <image :src="data.banner" class="collect-item__banner-icon" />
    </div>
    <div
      :class="[data.banner ? 'has-banner' : 'no-banner']"
      class="collect-item__info"
    >
      <div className="collect-item__info-title">
        {{ data.name }}
      </div>
      <div class="collect-item__info-detail">
        <span>作者：{{ data.author }}</span>
        <span>{{ data.createdAt }}</span>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ICollectArtical } from "@/apis/types/home";

defineOptions({
  name: "collect-item",
});

withDefaults(
  defineProps<{
    data: ICollectArtical;
    hasBanner?: boolean;
  }>(),
  {
    hasBanner: true,
  }
);
</script>

<style lang="less">
.collect-item {
  box-sizing: border-box;
  padding: 24px;
  border-radius: 20px;
  background-color: white;
  display: flex;
  align-items: stretch;
  gap: 20px;
  &:not(:last-child) {
    margin-bottom: 20px;
  }
  &__banner {
    width: 160px;
    height: 160px;
    display: flex;
    justify-content: center;
    align-items: center;
    image {
      width: auto;
      height: 100%;
    }
  }
  &__info {
    // background-color: red;
    width: 0;
    height: 100%;
    flex: 1;
    display: inline-flex;
    flex-direction: column;
    &.has-banner {
      height: 160px;
      justify-content: space-between;
    }
    &.no-banner {
      gap: 20px;
    }
    // gap: 20px;
    &-title {
      font-weight: 500;
      font-size: 28px;
      color: #000000;
      line-height: 40px;

      display: -webkit-box;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 2; /* 限制在这个元素显示的文本的行数为2行 */
      line-clamp: 2;
      overflow: hidden; /* 隐藏超出部分 */
    }
    &-detail {
      width: 100%;
      display: flex;
      justify-content: space-between;
      align-items: center;

      font-weight: 400;
      font-size: 24px;
      color: #8b8b8b;
      line-height: 34px;
    }
  }
}
</style>
